<template>
  <div>
    <h1>当前求和为：{{$store.state.sum}}</h1>
    <!-- <select v-model="num">
        <option :value="1">1</option>
        <option :value="2">2</option>
        <option :value="3">3</option>
    </select> -->
     <select v-model.number="num">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
    </select>
    <button @click="add">+</button>
    <button @click="substract">-</button>
    <button @click="jishu">当前求和为奇数在加</button>
    <button @click="wait">等一等再加</button>
  </div>
</template>

<script>
export default {
    name:'Count',
    data(){
        return {
            num:1
            
        }
    },

    methods:{
        add(){
           this.$store.commit('JIA', this.num)
        },
        substract(){
            this.$store.commit('JIAN', this.num)
        },
        jishu(){
            this.$store.dispatch('jishu', this.num)
        },
        wait(){
           this.$store.dispatch('wait', this.num)
        }
    },

}
</script>

<style scoped>

    div > *{
        margin: 5px;
    }
</style>